package design.observer;

import java.util.ArrayList;
import java.util.List;

public class WeatherStation implements Subject{
    private List<Observer> observerList = new ArrayList<>();
    private String weather;
    @Override
    public void addObserver(Observer observer) {
        observerList.add(observer);
    }

    @Override
    public void removeObserver(Observer observer) {
        observerList.remove(observer);
    }

    @Override
    public void notityObservers() {
        for (Observer observer : observerList) {
            observer.update(weather);

        }
    }
    public void setWeather(String weather){
        this.weather  = weather;
        notityObservers();
    }
}
